#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <string.h>
#include <ESP8266WiFi.h>
#include "Ticker.h"；
#include <DHT.h>

#define DHTPIN 2     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11   // DHT 11

extern int flag;
extern float temperature;
extern float humidity;
extern String infoJson;
extern String deviceId;
extern unsigned long previousMillis;        // will store last temp was read
extern const long interval;    

extern DHT dht;
extern WiFiClient espClient;
extern PubSubClient client;
extern Ticker myTicker;
extern const char* mqtt_server;

//连接mqtt
void reconnect();
//消息回调
void callback(char* topic, byte* payload, unsigned int length);
//连接wifi
void setup_wifi();
//发布注册消息
void sendRegisterMsg();
//订阅主题
void subscribeTopic();
//获取注册消息的jsonString
String getRegisterJsonString();
//根据收到的payload转化成消息String
String getMsgStringByPayload(byte* payload,int length);
//心跳任务
void tickerHandle(); 
//温湿度上传任务
void tempHumidityHandle();
